
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>数据模板 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Syntax-Specification.html" />
    
    
    <link rel="prev" href="Getting-Started.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="Getting-Started.html">
            
                <a href="Getting-Started.html">
            
                    
                    开始 & 安装
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3" data-path="Syntax-Specification.html">
            
                <a href="Syntax-Specification.html">
            
                    
                    数据模板
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="Syntax-Specification.html">
            
                <a href="Syntax-Specification.html#数据模板定义规范-dtd">
            
                    
                    数据模板定义规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="Syntax-Specification.html">
            
                <a href="Syntax-Specification.html#1-属性值是字符串-string">
            
                    
                    String
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="Syntax-Specification.html">
            
                <a href="Syntax-Specification.html#2-属性值是数字-number">
            
                    
                    Number
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="Syntax-Specification.html">
            
                <a href="Syntax-Specification.html#3-属性值是布尔型-boolean">
            
                    
                    Boolean
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="Syntax-Specification.html">
            
                <a href="Syntax-Specification.html#4-属性值是对象-object">
            
                    
                    Object
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="Syntax-Specification.html">
            
                <a href="Syntax-Specification.html#5-属性值是数组-array">
            
                    
                    Array
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="Syntax-Specification.html">
            
                <a href="Syntax-Specification.html#6-属性值是函数-function">
            
                    
                    Function
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="Syntax-Specification.html">
            
                <a href="Syntax-Specification.html#7-属性值是正则表达式-regexp">
            
                    
                    RegExp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="Syntax-Specification.html">
            
                <a href="Syntax-Specification.html#数据占位符定义规范-dtd">
            
                    
                    数据占位符定义规范
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="Mock.mock.html">
            
                <a href="Mock.mock.html">
            
                    
                    Mock.mock()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="Mock.setup.html">
            
                <a href="Mock.setup.html">
            
                    
                    Mock.setup()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="Mock.Random.html">
            
                <a href="Mock.Random.html">
            
                    
                    Mock.Random()
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="Basic.html">
            
                <a href="Basic.html">
            
                    
                    Basic
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1.1" data-path="Basic.html">
            
                <a href="Basic.html#randomboolean-min-max-current-">
            
                    
                    boolean
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.1.2" data-path="Basic.html">
            
                <a href="Basic.html#randomnatural-min-max-">
            
                    
                    natural
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.1.3" data-path="Basic.html">
            
                <a href="Basic.html#randominteger-min-max-">
            
                    
                    integer
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.1.4" data-path="Basic.html">
            
                <a href="Basic.html#randomfloat-min-max-dmin-dmax-">
            
                    
                    float
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.1.5" data-path="Basic.html">
            
                <a href="Basic.html#randomcharacter-pool-">
            
                    
                    character
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.1.6" data-path="Basic.html">
            
                <a href="Basic.html#randomstring-pool-min-max-">
            
                    
                    string
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.1.7" data-path="Basic.html">
            
                <a href="Basic.html#randomrange-start-stop-step-">
            
                    
                    range
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="Date.html">
            
                <a href="Date.html">
            
                    
                    Date
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.2.1" data-path="Date.html">
            
                <a href="Date.html#randomdate-format-">
            
                    
                    date
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2.2" data-path="Date.html">
            
                <a href="Date.html#randomtime-format-">
            
                    
                    timeDate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2.3" data-path="Date.html">
            
                <a href="Date.html#randomdatetime-format-">
            
                    
                    datetime
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2.4" data-path="Date.html">
            
                <a href="Date.html#randomnow-unit-format-">
            
                    
                    now
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="Image.html">
            
                <a href="Image.html">
            
                    
                    Image
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.3.1" data-path="Image.html">
            
                <a href="Image.html">
            
                    
                    img
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.2" data-path="Image.html">
            
                <a href="Image.html">
            
                    
                    dataImage
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="Color.html">
            
                <a href="Color.html">
            
                    
                    Color
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.4.1" data-path="Color.html">
            
                <a href="Color.html#randomcolor">
            
                    
                    color
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4.2" data-path="Color.html">
            
                <a href="Color.html#randomhex">
            
                    
                    hex
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4.3" data-path="Color.html">
            
                <a href="Color.html#randomrgb">
            
                    
                    rgb
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4.4" data-path="Color.html">
            
                <a href="Color.html#randomhsl">
            
                    
                    hsl
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="Text.html">
            
                <a href="Text.html">
            
                    
                    Text
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.5.1" data-path="Text.html">
            
                <a href="Text.html#randomparagraph-min-max-">
            
                    
                    paragraph
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5.2" data-path="Text.html">
            
                <a href="Text.html#randomsentence-min-max-">
            
                    
                    sentence
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5.3" data-path="Text.html">
            
                <a href="Text.html#randomword-min-max-">
            
                    
                    word
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5.4" data-path="Text.html">
            
                <a href="Text.html#randomtitle-min-max-">
            
                    
                    title
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5.5" data-path="Text.html">
            
                <a href="Text.html#randomcparagraph-min-max-">
            
                    
                    cparagraph
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5.6" data-path="Text.html">
            
                <a href="Text.html#randomcsentence-min-max-">
            
                    
                    csentence
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5.7" data-path="Text.html">
            
                <a href="Text.html#randomcword-pool-min-max-">
            
                    
                    cword
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5.8" data-path="Text.html">
            
                <a href="Text.html#randomctitle-min-max-">
            
                    
                    ctitlec
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="Name.html">
            
                <a href="Name.html">
            
                    
                    Name
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="Web.html">
            
                <a href="Web.html">
            
                    
                    Web
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="Address.html">
            
                <a href="Address.html">
            
                    
                    Address
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="Helper.html">
            
                <a href="Helper.html">
            
                    
                    Helper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="Miscellaneous.html">
            
                <a href="Miscellaneous.html">
            
                    
                    Miscellaneous
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="Mock.valid.html">
            
                <a href="Mock.valid.html">
            
                    
                    Mock.valid()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="Mock.toJSONSchema.html">
            
                <a href="Mock.toJSONSchema.html">
            
                    
                    Mock.toJSONSchema()
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="Thanks-&-Contributors.html">
            
                <a href="Thanks-&-Contributors.html">
            
                    
                    感谢 & 贡献者
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >数据模板</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x8BED;&#x6CD5;&#x89C4;&#x8303;">&#x8BED;&#x6CD5;&#x89C4;&#x8303;</h1>
<p>Mock.js &#x7684;&#x8BED;&#x6CD5;&#x89C4;&#x8303;&#x5305;&#x62EC;&#x4E24;&#x90E8;&#x5206;&#xFF1A;</p>
<ol>
<li>&#x6570;&#x636E;&#x6A21;&#x677F;&#x5B9A;&#x4E49;&#x89C4;&#x8303;&#xFF08;Data Template Definition&#xFF0C;DTD&#xFF09;</li>
<li>&#x6570;&#x636E;&#x5360;&#x4F4D;&#x7B26;&#x5B9A;&#x4E49;&#x89C4;&#x8303;&#xFF08;Data Placeholder Definition&#xFF0C;DPD&#xFF09;</li>
</ol>
<h2 id="&#x6570;&#x636E;&#x6A21;&#x677F;&#x5B9A;&#x4E49;&#x89C4;&#x8303;-dtd">&#x6570;&#x636E;&#x6A21;&#x677F;&#x5B9A;&#x4E49;&#x89C4;&#x8303; DTD</h2>
<p><strong>&#x6570;&#x636E;&#x6A21;&#x677F;&#x4E2D;&#x7684;&#x6BCF;&#x4E2A;&#x5C5E;&#x6027;&#x7531; 3 &#x90E8;&#x5206;&#x6784;&#x6210;&#xFF1A;&#x5C5E;&#x6027;&#x540D;&#x3001;&#x751F;&#x6210;&#x89C4;&#x5219;&#x3001;&#x5C5E;&#x6027;&#x503C;&#xFF1A;</strong></p>
<pre><code class="lang-js"><span class="hljs-comment">// &#x5C5E;&#x6027;&#x540D;   name</span>
<span class="hljs-comment">// &#x751F;&#x6210;&#x89C4;&#x5219; rule</span>
<span class="hljs-comment">// &#x5C5E;&#x6027;&#x503C;   value</span>
<span class="hljs-string">&apos;name|rule&apos;</span>: value
</code></pre>
<p><strong>&#x6CE8;&#x610F;&#xFF1A;</strong></p>
<ul>
<li><em>&#x5C5E;&#x6027;&#x540D;</em> &#x548C; <em>&#x751F;&#x6210;&#x89C4;&#x5219;</em> &#x4E4B;&#x95F4;&#x7528;&#x7AD6;&#x7EBF; <code>|</code> &#x5206;&#x9694;&#x3002;</li>
<li><em>&#x751F;&#x6210;&#x89C4;&#x5219;</em> &#x662F;&#x53EF;&#x9009;&#x7684;&#x3002;</li>
<li><em>&#x751F;&#x6210;&#x89C4;&#x5219;</em> &#x6709; 7 &#x79CD;&#x683C;&#x5F0F;&#xFF1A;<ol>
<li><code>&apos;name|min-max&apos;: value</code></li>
<li><code>&apos;name|count&apos;: value</code></li>
<li><code>&apos;name|min-max.dmin-dmax&apos;: value</code></li>
<li><code>&apos;name|min-max.dcount&apos;: value</code></li>
<li><code>&apos;name|count.dmin-dmax&apos;: value</code></li>
<li><code>&apos;name|count.dcount&apos;: value</code></li>
<li><code>&apos;name|+step&apos;: value</code></li>
</ol>
</li>
<li><strong><em>&#x751F;&#x6210;&#x89C4;&#x5219;</em> &#x7684; &#x542B;&#x4E49; &#x9700;&#x8981;&#x4F9D;&#x8D56; <em>&#x5C5E;&#x6027;&#x503C;&#x7684;&#x7C7B;&#x578B;</em> &#x624D;&#x80FD;&#x786E;&#x5B9A;&#x3002;</strong></li>
<li><em>&#x5C5E;&#x6027;&#x503C;</em> &#x4E2D;&#x53EF;&#x4EE5;&#x542B;&#x6709; <code>@&#x5360;&#x4F4D;&#x7B26;</code>&#x3002;</li>
<li><em>&#x5C5E;&#x6027;&#x503C;</em> &#x8FD8;&#x6307;&#x5B9A;&#x4E86;&#x6700;&#x7EC8;&#x503C;&#x7684;&#x521D;&#x59CB;&#x503C;&#x548C;&#x7C7B;&#x578B;&#x3002;</li>
</ul>
<!-- 感谢 @麦少 同学对 Mock.js 语法的整理和分析，才有了这版相对清晰的语法文档。 -->
<p><strong>&#x751F;&#x6210;&#x89C4;&#x5219;&#x548C;&#x793A;&#x4F8B;&#xFF1A;</strong></p>
<h3 id="1-&#x5C5E;&#x6027;&#x503C;&#x662F;&#x5B57;&#x7B26;&#x4E32;-string">1. &#x5C5E;&#x6027;&#x503C;&#x662F;&#x5B57;&#x7B26;&#x4E32; <strong>String</strong></h3>
<ol>
<li><p><code>&apos;name|min-max&apos;: string</code> </p>
<p> &#x901A;&#x8FC7;&#x91CD;&#x590D; <code>string</code> &#x751F;&#x6210;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x91CD;&#x590D;&#x6B21;&#x6570;&#x5927;&#x4E8E;&#x7B49;&#x4E8E; <code>min</code>&#xFF0C;&#x5C0F;&#x4E8E;&#x7B49;&#x4E8E; <code>max</code>&#x3002;</p>
</li>
<li><p><code>&apos;name|count&apos;: string</code> </p>
<p> &#x901A;&#x8FC7;&#x91CD;&#x590D; <code>string</code> &#x751F;&#x6210;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x91CD;&#x590D;&#x6B21;&#x6570;&#x7B49;&#x4E8E; <code>count</code>&#x3002;</p>
</li>
</ol>
<h3 id="2-&#x5C5E;&#x6027;&#x503C;&#x662F;&#x6570;&#x5B57;-number">2. &#x5C5E;&#x6027;&#x503C;&#x662F;&#x6570;&#x5B57; <strong>Number</strong></h3>
<ol>
<li><p><code>&apos;name|+1&apos;: number</code> </p>
<p> &#x5C5E;&#x6027;&#x503C;&#x81EA;&#x52A8;&#x52A0; 1&#xFF0C;&#x521D;&#x59CB;&#x503C;&#x4E3A; <code>number</code>&#x3002;</p>
</li>
<li><p><code>&apos;name|min-max&apos;: number</code> </p>
<p> &#x751F;&#x6210;&#x4E00;&#x4E2A;&#x5927;&#x4E8E;&#x7B49;&#x4E8E; <code>min</code>&#x3001;&#x5C0F;&#x4E8E;&#x7B49;&#x4E8E; <code>max</code> &#x7684;&#x6574;&#x6570;&#xFF0C;&#x5C5E;&#x6027;&#x503C; <code>number</code> &#x53EA;&#x662F;&#x7528;&#x6765;&#x786E;&#x5B9A;&#x7C7B;&#x578B;&#x3002;</p>
</li>
<li><p><code>&apos;name|min-max.dmin-dmax&apos;: number</code> </p>
<p> &#x751F;&#x6210;&#x4E00;&#x4E2A;&#x6D6E;&#x70B9;&#x6570;&#xFF0C;&#x6574;&#x6570;&#x90E8;&#x5206;&#x5927;&#x4E8E;&#x7B49;&#x4E8E; <code>min</code>&#x3001;&#x5C0F;&#x4E8E;&#x7B49;&#x4E8E; <code>max</code>&#xFF0C;&#x5C0F;&#x6570;&#x90E8;&#x5206;&#x4FDD;&#x7559; <code>dmin</code> &#x5230; <code>dmax</code> &#x4F4D;&#x3002;</p>
</li>
</ol>
<pre><code class="lang-js">Mock.mock({
    <span class="hljs-string">&apos;number1|1-100.1-10&apos;</span>: <span class="hljs-number">1</span>,
    <span class="hljs-string">&apos;number2|123.1-10&apos;</span>: <span class="hljs-number">1</span>,
    <span class="hljs-string">&apos;number3|123.3&apos;</span>: <span class="hljs-number">1</span>,
    <span class="hljs-string">&apos;number4|123.10&apos;</span>: <span class="hljs-number">1.123</span>
})
<span class="hljs-comment">// =&gt;</span>
{
    <span class="hljs-string">&quot;number1&quot;</span>: <span class="hljs-number">12.92</span>,
    <span class="hljs-string">&quot;number2&quot;</span>: <span class="hljs-number">123.51</span>,
    <span class="hljs-string">&quot;number3&quot;</span>: <span class="hljs-number">123.777</span>,
    <span class="hljs-string">&quot;number4&quot;</span>: <span class="hljs-number">123.1231091814</span>
}
</code></pre>
<h3 id="3-&#x5C5E;&#x6027;&#x503C;&#x662F;&#x5E03;&#x5C14;&#x578B;-boolean">3. &#x5C5E;&#x6027;&#x503C;&#x662F;&#x5E03;&#x5C14;&#x578B; <strong>Boolean</strong></h3>
<ol>
<li><p><code>&apos;name|1&apos;: boolean</code> </p>
<p> &#x968F;&#x673A;&#x751F;&#x6210;&#x4E00;&#x4E2A;&#x5E03;&#x5C14;&#x503C;&#xFF0C;&#x503C;&#x4E3A; true &#x7684;&#x6982;&#x7387;&#x662F; 1/2&#xFF0C;&#x503C;&#x4E3A; false &#x7684;&#x6982;&#x7387;&#x540C;&#x6837;&#x662F; 1/2&#x3002;</p>
</li>
<li><p><code>&apos;name|min-max&apos;: value</code> </p>
<p> &#x968F;&#x673A;&#x751F;&#x6210;&#x4E00;&#x4E2A;&#x5E03;&#x5C14;&#x503C;&#xFF0C;&#x503C;&#x4E3A; <code>value</code> &#x7684;&#x6982;&#x7387;&#x662F; <code>min / (min + max)</code>&#xFF0C;&#x503C;&#x4E3A; <code>!value</code> &#x7684;&#x6982;&#x7387;&#x662F; <code>max / (min + max)</code>&#x3002;</p>
</li>
</ol>
<h3 id="4-&#x5C5E;&#x6027;&#x503C;&#x662F;&#x5BF9;&#x8C61;-object">4. &#x5C5E;&#x6027;&#x503C;&#x662F;&#x5BF9;&#x8C61; <strong>Object</strong></h3>
<ol>
<li><p><code>&apos;name|count&apos;: object</code></p>
<p> &#x4ECE;&#x5C5E;&#x6027;&#x503C; <code>object</code> &#x4E2D;&#x968F;&#x673A;&#x9009;&#x53D6; <code>count</code> &#x4E2A;&#x5C5E;&#x6027;&#x3002;</p>
</li>
<li><p><code>&apos;name|min-max&apos;: object</code></p>
<p> &#x4ECE;&#x5C5E;&#x6027;&#x503C; <code>object</code> &#x4E2D;&#x968F;&#x673A;&#x9009;&#x53D6; <code>min</code> &#x5230; <code>max</code> &#x4E2A;&#x5C5E;&#x6027;&#x3002;</p>
</li>
</ol>
<h3 id="5-&#x5C5E;&#x6027;&#x503C;&#x662F;&#x6570;&#x7EC4;-array">5. &#x5C5E;&#x6027;&#x503C;&#x662F;&#x6570;&#x7EC4; <strong>Array</strong></h3>
<ol>
<li><p><code>&apos;name|1&apos;: array</code> </p>
<p> &#x4ECE;&#x5C5E;&#x6027;&#x503C; <code>array</code> &#x4E2D;&#x968F;&#x673A;&#x9009;&#x53D6; 1 &#x4E2A;&#x5143;&#x7D20;&#xFF0C;&#x4F5C;&#x4E3A;&#x6700;&#x7EC8;&#x503C;&#x3002;</p>
</li>
<li><p><code>&apos;name|+1&apos;: array</code> </p>
<p> &#x4ECE;&#x5C5E;&#x6027;&#x503C; <code>array</code> &#x4E2D;&#x987A;&#x5E8F;&#x9009;&#x53D6; 1 &#x4E2A;&#x5143;&#x7D20;&#xFF0C;&#x4F5C;&#x4E3A;&#x6700;&#x7EC8;&#x503C;&#x3002;</p>
</li>
<li><p><code>&apos;name|min-max&apos;: array</code> </p>
<p> &#x901A;&#x8FC7;&#x91CD;&#x590D;&#x5C5E;&#x6027;&#x503C; <code>array</code> &#x751F;&#x6210;&#x4E00;&#x4E2A;&#x65B0;&#x6570;&#x7EC4;&#xFF0C;&#x91CD;&#x590D;&#x6B21;&#x6570;&#x5927;&#x4E8E;&#x7B49;&#x4E8E; <code>min</code>&#xFF0C;&#x5C0F;&#x4E8E;&#x7B49;&#x4E8E; <code>max</code>&#x3002;</p>
</li>
<li><p><code>&apos;name|count&apos;: array</code> </p>
<p> &#x901A;&#x8FC7;&#x91CD;&#x590D;&#x5C5E;&#x6027;&#x503C; <code>array</code> &#x751F;&#x6210;&#x4E00;&#x4E2A;&#x65B0;&#x6570;&#x7EC4;&#xFF0C;&#x91CD;&#x590D;&#x6B21;&#x6570;&#x4E3A; <code>count</code>&#x3002;</p>
</li>
</ol>
<h3 id="6-&#x5C5E;&#x6027;&#x503C;&#x662F;&#x51FD;&#x6570;-function">6. &#x5C5E;&#x6027;&#x503C;&#x662F;&#x51FD;&#x6570; <strong>Function</strong></h3>
<ol>
<li><p><code>&apos;name&apos;: function</code> </p>
<p> &#x6267;&#x884C;&#x51FD;&#x6570; <code>function</code>&#xFF0C;&#x53D6;&#x5176;&#x8FD4;&#x56DE;&#x503C;&#x4F5C;&#x4E3A;&#x6700;&#x7EC8;&#x7684;&#x5C5E;&#x6027;&#x503C;&#xFF0C;&#x51FD;&#x6570;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x4E3A;&#x5C5E;&#x6027; <code>&apos;name&apos;</code> &#x6240;&#x5728;&#x7684;&#x5BF9;&#x8C61;&#x3002;</p>
</li>
</ol>
<h3 id="7-&#x5C5E;&#x6027;&#x503C;&#x662F;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;-regexp">7. &#x5C5E;&#x6027;&#x503C;&#x662F;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F; <strong>RegExp</strong></h3>
<ol>
<li><p><code>&apos;name&apos;: regexp</code> </p>
<p> &#x6839;&#x636E;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F; <code>regexp</code> &#x53CD;&#x5411;&#x751F;&#x6210;&#x53EF;&#x4EE5;&#x5339;&#x914D;&#x5B83;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x3002;&#x7528;&#x4E8E;&#x751F;&#x6210;&#x81EA;&#x5B9A;&#x4E49;&#x683C;&#x5F0F;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x3002;</p>
<pre><code class="lang-js"> Mock.mock({
     <span class="hljs-string">&apos;regexp1&apos;</span>: <span class="hljs-regexp">/[a-z][A-Z][0-9]/</span>,
     <span class="hljs-string">&apos;regexp2&apos;</span>: <span class="hljs-regexp">/\w\W\s\S\d\D/</span>,
     <span class="hljs-string">&apos;regexp3&apos;</span>: <span class="hljs-regexp">/\d{5,10}/</span>
 })
 <span class="hljs-comment">// =&gt;</span>
 {
     <span class="hljs-string">&quot;regexp1&quot;</span>: <span class="hljs-string">&quot;pJ7&quot;</span>,
     <span class="hljs-string">&quot;regexp2&quot;</span>: <span class="hljs-string">&quot;F)\fp1G&quot;</span>,
     <span class="hljs-string">&quot;regexp3&quot;</span>: <span class="hljs-string">&quot;561659409&quot;</span>
 }
</code></pre>
</li>
</ol>
<h2 id="&#x6570;&#x636E;&#x5360;&#x4F4D;&#x7B26;&#x5B9A;&#x4E49;&#x89C4;&#x8303;-dpd">&#x6570;&#x636E;&#x5360;&#x4F4D;&#x7B26;&#x5B9A;&#x4E49;&#x89C4;&#x8303; DPD</h2>
<p><em>&#x5360;&#x4F4D;&#x7B26;</em> &#x53EA;&#x662F;&#x5728;&#x5C5E;&#x6027;&#x503C;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x5360;&#x4E2A;&#x4F4D;&#x7F6E;&#xFF0C;&#x5E76;&#x4E0D;&#x51FA;&#x73B0;&#x5728;&#x6700;&#x7EC8;&#x7684;&#x5C5E;&#x6027;&#x503C;&#x4E2D;&#x3002;</p>
<p><em>&#x5360;&#x4F4D;&#x7B26;</em> &#x7684;&#x683C;&#x5F0F;&#x4E3A;&#xFF1A;</p>
<pre><code>@&#x5360;&#x4F4D;&#x7B26;
@&#x5360;&#x4F4D;&#x7B26;(&#x53C2;&#x6570; [, &#x53C2;&#x6570;])
</code></pre><p><strong>&#x6CE8;&#x610F;&#xFF1A;</strong></p>
<ol>
<li>&#x7528; <code>@</code> &#x6765;&#x6807;&#x8BC6;&#x5176;&#x540E;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x662F; <em>&#x5360;&#x4F4D;&#x7B26;</em>&#x3002;</li>
<li><em>&#x5360;&#x4F4D;&#x7B26;</em> &#x5F15;&#x7528;&#x7684;&#x662F; <code>Mock.Random</code> &#x4E2D;&#x7684;&#x65B9;&#x6CD5;&#x3002;</li>
<li>&#x901A;&#x8FC7; <code>Mock.Random.extend()</code> &#x6765;&#x6269;&#x5C55;&#x81EA;&#x5B9A;&#x4E49;&#x5360;&#x4F4D;&#x7B26;&#x3002;</li>
<li><em>&#x5360;&#x4F4D;&#x7B26;</em> &#x4E5F;&#x53EF;&#x4EE5;&#x5F15;&#x7528; <em>&#x6570;&#x636E;&#x6A21;&#x677F;</em> &#x4E2D;&#x7684;&#x5C5E;&#x6027;&#x3002;</li>
<li><em>&#x5360;&#x4F4D;&#x7B26;</em> &#x4F1A;&#x4F18;&#x5148;&#x5F15;&#x7528; <em>&#x6570;&#x636E;&#x6A21;&#x677F;</em> &#x4E2D;&#x7684;&#x5C5E;&#x6027;&#x3002;</li>
<li><em>&#x5360;&#x4F4D;&#x7B26;</em> &#x652F;&#x6301; <em>&#x76F8;&#x5BF9;&#x8DEF;&#x5F84;</em> &#x548C; <em>&#x7EDD;&#x5BF9;&#x8DEF;&#x5F84;</em>&#x3002;</li>
</ol>
<pre><code class="lang-js">Mock.mock({
    name: {
        first: <span class="hljs-string">&apos;@FIRST&apos;</span>,
        middle: <span class="hljs-string">&apos;@FIRST&apos;</span>,
        last: <span class="hljs-string">&apos;@LAST&apos;</span>,
        full: <span class="hljs-string">&apos;@first @middle @last&apos;</span>
    }
})
<span class="hljs-comment">// =&gt;</span>
{
    <span class="hljs-string">&quot;name&quot;</span>: {
        <span class="hljs-string">&quot;first&quot;</span>: <span class="hljs-string">&quot;Charles&quot;</span>,
        <span class="hljs-string">&quot;middle&quot;</span>: <span class="hljs-string">&quot;Brenda&quot;</span>,
        <span class="hljs-string">&quot;last&quot;</span>: <span class="hljs-string">&quot;Lopez&quot;</span>,
        <span class="hljs-string">&quot;full&quot;</span>: <span class="hljs-string">&quot;Charles Brenda Lopez&quot;</span>
    }
}
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="Getting-Started.html" class="navigation navigation-prev " aria-label="Previous page: 开始 & 安装">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="Syntax-Specification.html#数据模板定义规范-dtd" class="navigation navigation-next " aria-label="Next page: 数据模板定义规范">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"数据模板","level":"1.3","depth":1,"next":{"title":"数据模板定义规范","level":"1.3.1","depth":2,"anchor":"#数据模板定义规范-dtd","path":"Syntax-Specification.md","ref":"./Syntax-Specification.md#数据模板定义规范-dtd","articles":[]},"previous":{"title":"开始 & 安装","level":"1.2","depth":1,"path":"Getting-Started.md","ref":"./Getting-Started.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"Syntax-Specification.md","mtime":"2019-01-02T03:55:46.299Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-01-02T04:01:33.354Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

